package com.csgc.camera.biz.other.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.csgc.camera.base.BaseBindingActivity
import com.csgc.camera.constants.Constants
import com.csgc.camera.events.showMaskEditDialogEvent
import com.csgc.camera.util.clickWithTrigger
import com.csgc.camera.widget.dialog.ContactUsDialog
import com.cysd.spsyxj.R
import com.cysd.spsyxj.databinding.ActivityUserCenterBinding
import com.drake.channel.sendEvent
import com.gyf.immersionbar.ktx.immersionBar
import com.hlyj.http.ad.NewGroMoreFeedAdManager
import com.hnyyac.ad.mds.utils.BaseAdConstants

class UserCenterActivity : BaseBindingActivity<ActivityUserCenterBinding> (ActivityUserCenterBinding::inflate) {

    private val qqDialog:ContactUsDialog by lazy {
        ContactUsDialog(this)
    }

    //launch
    companion object {
        fun launch(context: Context) {
            context.startActivity(Intent(context, UserCenterActivity::class.java))
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        immersionBar {
            //界面在状态栏底部true   界面在状态栏下面沉浸式盖着界面false
            fitsSystemWindows(false)
            //白色状态栏，黑色字体
            statusBarColor(R.color.transparent)
            statusBarDarkFont(true)
        }
        initLister()
        loadFeed()
    }

    private fun loadFeed() {
        val newGromoreFeedAd = NewGroMoreFeedAdManager(
            this@UserCenterActivity,
            BaseAdConstants.FEEDAD_Id, binding.feedContainer, 66
        )
        newGromoreFeedAd.loadAd()
    }

    private fun initLister() {
        binding.apply {
            sbLogoWaterMark.setOnCheckedChangeListener { buttonView, isChecked ->
                sendEvent(showMaskEditDialogEvent(isChecked))
            }
            layoutCameraSetting.clickWithTrigger {
                CameraSettingActivity.launch(this@UserCenterActivity)
            }

            ivBack.clickWithTrigger {
                finish()
            }



            layoutUserProtocol.clickWithTrigger {
                WebViewActivity.launch(this@UserCenterActivity,"用户服务协议", Constants.PrivacyUrl.protocol.url)
            }
            layoutPrivacy.clickWithTrigger {
                WebViewActivity.launch(this@UserCenterActivity,"隐私政策",Constants.PrivacyUrl.privacy.url)
            }

            layoutFeedBack.clickWithTrigger {
                FeedBackActivity.launch(this@UserCenterActivity)
            }
            layoutAboutUs.clickWithTrigger {
                AboutActivity.launch(this@UserCenterActivity)
            }

            layoutContactUs.clickWithTrigger {
                qqDialog.show()
            }

        }
    }
}